#!/usr/bin/python
# -*- coding: UTF-8 -*-
#以人人网为例
import requests

# session = requests.session()
# url = "http://www.renren.com/PLogin.do"
# headers = {
#     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36"}
# date = {
#     "email": "15869117206",
#     "password": "a588181"
# }
# session.post(url, headers=headers, data=date)
# url1 = "http://www.renren.com/966470757/profile"
# session.get(url1)



# import re
# import urllib.request
 
# #定义一个爬取网络小说的函数
# def getNovelContent():
#     html = urllib.request.urlopen("http://www.quanshuwang.com/book/44/44683").read()
#     html = html.decode("gbk")   #转成该网址的格式
#     #<li><a href="http://www.quanshuwang.com/book/44/44683/15379609.html" title="引子 穿越的唐家三少，共2744字">引子 穿越的唐家三少</a></li>  #参考
#     reg = r'<li><a href="(.*?)" title=".*?">(.*?)</a></li>'     #正则表达的匹配
#     reg = re.compile(reg)     #可添加可不添加，增加效率
#     urls = re.findall(reg,html)
#     for url in urls:
#         #print(url)
#         chapter_url = url[0]  #章节的超链接
#         chapter_title = url[1]  #章节的名字
#         #print(chapter_title)
#         chapter_html = urllib.request.urlopen(chapter_url).read()   #正文内容源代码
#         chapter_html = chapter_html.decode("gbk")
#         chapter_reg = r'</script>&nbsp;&nbsp;&nbsp;&nbsp;.*?<br />(.*?)<script type="text/javascript">'
#         chapter_reg = re.compile(chapter_reg,re.S)
#         chapter_content = re.findall(chapter_reg,chapter_html)
#         for content in chapter_content:
#             content = content.replace("&nbsp;&nbsp;&nbsp;&nbsp;","")
#             content = content.replace("<br />","")
#            # print(content)
#             f = open('{}.txt'.format(chapter_title),'w')
#             f.write(content)
 
# getNovelContent()


fundCode = '000001'
pageIndex = 1
url = 'http://api.fund.eastmoney.com/f10/lsjz'

# 参数化访问链接，以dict方式存储
params = {
    'callback': 'jQuery18307633215694564663_1548321266367',
    'fundCode': fundCode,
    'pageIndex': pageIndex,
    'pageSize': 20,
}
# 存储cookie内容
cookie = 'EMFUND1=null; EMFUND2=null; EMFUND3=null; EMFUND4=null; EMFUND5=null; EMFUND6=null; EMFUND7=null; EMFUND8=null; EMFUND0=null; EMFUND9=01-24 17:11:50@#$%u957F%u4FE1%u5229%u5E7F%u6DF7%u5408A@%23%24519961; st_pvi=27838598767214; st_si=11887649835514'
# 装饰头文件
headers = {
    'Cookie': cookie,
    'Host': 'api.fund.eastmoney.com',
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
    'Referer': 'http://fundf10.eastmoney.com/jjjz_%s.html' % fundCode,
}
r = requests.get(url=url, headers=headers, params=params)  # 发送请求

print(r.text)